<template>
  <div>
    <input type="text" v-if="isShow" ref="input" />
    <button v-else @click="sub">搜索</button>
  </div>
</template>
 
<script>
export default {
  props: {},
  data() {
    return {
      isShow: false,
    };
  },
  methods: {
    sub() {
      this.isShow = !this.isShow;
      this.$nextTick(() => {
        this.$refs.input.focus();
      });
    },
  },
};
</script>

<style scoped>
</style>